/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-04-24
 * Time: 17:24
 */
public class MyCircularQueue{ // 循环队列
    public int[] elem;
    public int usedSize;

    public MyCircularQueue(int k){
        this.elem = new int[k];
    }

    public void add(int data){
        if (this.usedSize == elem.length){
            System.out.println("循环队列已满 无法插入！");
            return;
        }
        elem[this.usedSize] = data;
        usedSize++;
    }


    public void remove(){
        if (usedSize == 0){
            System.out.println("循环队列为空 ！ 无法删除");
        }
        for (int i = 0; i < usedSize-1; i++) {
            elem[i] = elem[i+1];
        }
        usedSize--;
    }


    public int element(){
        if (usedSize == 0){
            System.out.println("循环队列为空！");
            return -1;
        }
        return elem[0];
    }
}
